package com.zmn.brs.common.enums;

import java.util.Optional;
import java.util.stream.Stream;

/**
 * 类描述：阀值表达式
 *
 * @author xujie
 * @since 2021/03/17 18:06
 */
public enum ThresholdExpressionEnum {

    /**
     *
     */
    NOT_IN("not_in", "不存在"),
    ALL("all", "所有"),
    TIME_FRAME("time_frame", "时间范围 HH:mm~HH:mm"),
    NOT_EQUALS("not_equals", "不相等"),
    EQUALS("equals", "相等"),
    GREATER_THAN_EQUAL("&gt;=", "大于等于"),
    IN("in", "存在"),
    ;

    /**
     * 表达式
     */
    private final String expression;

    /**
     * 说明
     */
    private final String explain;

    ThresholdExpressionEnum(String expression, String explain) {
        this.expression = expression;
        this.explain = explain;
    }

    public String getExpression() {

        return expression;
    }

    public String getExplain() {

        return explain;
    }

    public static ThresholdExpressionEnum getExpressionEnum(String expression) {

        Optional<ThresholdExpressionEnum> enumOptional = Stream.of(ThresholdExpressionEnum.values())
                .filter(p -> p.expression.equalsIgnoreCase(expression)).findFirst();
        return enumOptional.orElse(null);
    }

}
